$(function(){
    //登录框自动显示(弹性效果)
    // $('form').animate({top : '190px'},500);
    // $('form').animate({top : '150px'},200);

    //后台登陆由下到上
    allP = $('.four_bj').find('p');
    allP.eq(0).animate({left : 0,top : 0},500);
    allP.eq(1).animate({left : 235,top : 0},600);
    allP.eq(2).animate({left : 0,top : 122},700);
    allP.eq(3).animate({left : 235,top : 122},800);
    //验证码自动显示
    $('#verify_img').fadeIn(900);
    //网页加载自动获得焦点
    $('#userName').focus();

    
    $('#sub').click(function () {
        var username = $(this).parent().children('#userName').val();
        var password = $(this).parent().children('#psd').val();
        var captcha = $(this).parent().children('#verify').val();

        if (username == '' || password == '' || captcha == ''){
            alert('信息填写不全');
            return;
        }
        password = $.md5(password);
        $.ajax(
            {
                type: 'post',
                url: './admin/login/login_doing.html',
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                data:{
                    'email':username,
                    'password' : password,
                    'captcha':captcha
                },
                success:function (data) {
                    if (data == 'error_captcha'){
                        alert('验证码错');
                        return;
                    }
                    if (data == 'error_user_password'){
                        alert('用户名或密码错');
                        return;
                    }
                    window.open(data, '_self');
                },
                error:function (jqXHR, textStatus, errorMsg) {
                    alert(errorMsg);
                    window.location.reload();
                }
            }
        );
    });
})
